import java.sql.*;
import com.genexus.ui.*;
import com.genexus.db.*;
import com.genexus.*;

public final class gxrgzb extends GXProcedure
{
   public gxrgzb( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxrgzb.class ), "" );
   }

   public gxrgzb( int remoteHandle ,
                  ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /*
         This program controls table creation either for the creation or
         reorganization processes.
         Execute reorganization programs (none if creating the database).
      */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzrrpgm", new Object[] {"4"}) );
      GXReorganization.addMsg( localUtil.getMessages().getMessage("runpgm", new Object[] {"C52"}) );
      new c52(remoteHandle, context).execute( ) ;
      DBConnectionManager.getInstance(context).dropAllCursors(remoteHandle);
      Application.commit(context, remoteHandle, "DEFAULT", "gxrgzb") ;
      /* Creating final tables. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("filecrea", new Object[] {"MMMDA10",""}) );
      cmdBuffer = " DROP TABLE [MMMDA10] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE TABLE [MMMDA10] ([ModCod] char(10) NOT null , [ModNom] char(50) null , [ModEst] ";
      cmdBuffer += "  char(1) null , [ModFCR] datetime null , [ModHCR] char(8) null , [ModUCR] char(10) ";
      cmdBuffer += "  null , [ModFUM] datetime null , [ModHUM] char(8) null , [ModUUM] char(10) null , ";
      cmdBuffer += "  [MarCodAux] char(10) null , PRIMARY KEY([ModCod]))  ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Dropping temporary indexes. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("dropindx", new Object[] {"GXI52 (temp)"}) );
      cmdBuffer = " DROP INDEX [GXA0052].[GXI52] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cleanup();
   }

   protected void cleanup( )
   {
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      cmdBuffer = "" ;
      /* GeneXus formulas. */
   }

   protected String cmdBuffer ;
}

